import { httpGet, httpPost } from "@/utils/request"
import { IContentType } from "@/utils/enum"

/**
 * 首页
 */
export const getHomeData = (city: string) => httpGet<IApiRelative.IHome.IResData>("/home", { city })
/**
 * 艺考资讯首页
 */
export const getNewsData = () => httpGet<IApiRelative.IGetNewsData.IResData>("/news/index?v=v2")
/**
 * 艺考动态，指南，政策列表
 */
export const getExamList = (params: IApiRelative.IGetExamList.IParams) =>
  httpPost<IApiRelative.IGetExamList.IResData>("/news/grid", params, {
    header: {
      "content-type": IContentType.json
    }
  })
/**
 * 资讯详情
 * @param id 动态、指南、政策 ID
 */
export const getNewsDetail = (id: number | string) =>
  httpGet<IApiRelative.IGetNewsDetail.IResData>("/news/detail/" + id)
/**
 * 资讯详情-点赞
 * @param id 资讯ID
 */
export const newsLike = (id: number | string) => httpPost<unknown>("/news/like/" + id)
/**
 * 专业解读 列表
 */
export const getExplainList = () => httpGet<IApiRelative.IGetExplainList.IResData>("/project/grid")
/**
 * 专业解读 詳情
 */
export const getExplainDetail = (id: any) =>
  httpGet<IApiRelative.IGetExplainDetail.IResData>("/project/detail/" + id)
/**
 * 艺考问答 列表
 */
export const getQAList = (params: IApiRelative.IGetQAList.IParams) =>
  httpPost<IApiRelative.IGetQAList.IResData>("/question/grid", params, {
    header: {
      "content-type": IContentType.json
    }
  })
/**
 * 艺考问答 詳情
 * @param id 问题ID
 */
export const getQADetail = (id: number | string) =>
  httpGet<IApiRelative.IGetQADetail.IResData>("/question/detail/" + id)
/**
 * 艺考问答 詳情 点赞
 * @param id 问题ID
 */
export const qaDoLike = (id: number | string) => httpPost<unknown>("/question/answer-like/" + id)
/**
 * 艺考专题-文章 菜单
 */
export const getExamArticleMenu = () => httpGet<any>("/topic/menu")
/**
 * 艺考专题-文章 筛选
 */
export const filterExamArticle = (id: string | number) => httpGet<any>("/topic/items/" + id)
/**
 * 艺考专题-专题主页 详情
 * @param id
 */
export const getColumnDetail = (id: string | number) => httpGet<any>("/topic/detail/" + id)
/**
 * 艺考专题-艺考百科详情
 * @param id
 */
export const getKnownDetail = (id: string | number) =>
  httpGet<IApiRelative.IGetKnownDetail.IResData>("/wiki/detail/" + id)
/**
 * 艺考专题-艺考百科 首页
 */
export const getExamColumn = () => httpGet<IApiRelative.IGetExamColumn.IResData>("/wiki")
/**
 * 学校详情
 * @param id
 */
export const getSchoolDetail = (id: string | number) =>
  httpGet<IApiRelative.IGetSchoolDetail.IResData>("/school/" + id)
/**
 * 院校查询 筛选条件
 */
export const getSchoolFilters = () =>
  httpGet<IApiRelative.IGetSchoolFilters.IResData>("/school/option")
/**
 * 院校查询 列表
 */
export const getSchoolList = (params: IApiRelative.IGetSchoolList.IParams) =>
  httpPost<IApiRelative.IGetSchoolList.IResData>("/school", params, {
    header: {
      "content-type": IContentType.json
    }
  })
/**
 * 招生简章 筛选条件
 */
export const getBadgeFilters = () =>
  httpGet<IApiRelative.IGetBadgeFilters.IResData>("/school/recruit-option")
/**
 * 招生简章 列表
 */
export const getBadgeList = (params: IApiRelative.IGetBadgeList.IParams) =>
  httpPost<IApiRelative.IGetBadgeList.IResData>("/school/recruit-news", params, {
    header: {
      "content-type": IContentType.json
    }
  })
/**
 * 招生简章,院校资讯详情
 * @param id 招生简章ID、院校资讯ID
 */
export const getBadgeOrNewsDetail = (id: string | number) =>
  httpGet<IApiRelative.IGetBadgeOrNewsDetail.IResData>("/school/news/" + id)
/**
 * 机构详情
 * @param id 机构ID
 */
export const getInstitutionDetail = (id: string | number) =>
  httpGet<IApiRelative.IGetInstitutionDetail.IResData>("/agency/info/" + id)

export const getOrganizationDetail = (id: string | number) =>
  httpGet<IApiRelative.IGetOrganizationDetail.IResData>("/agency/template/" + id)

/**
 * 专业大全 筛选条件
 * @param level 学历层次 默认为空
 */
export const getProFilters = (level?: number) => {
  if (typeof level === "undefined" || level == null) {
    return httpGet<IApiRelative.IGetProFilters.IResData>("/subject/options")
  }
  return httpGet<IApiRelative.IGetProFilters.IResData>("/subject/options?level=" + level)
}
/**
 * 专业大全 列表
 */
export const getProList = (params: IApiRelative.IGetProList.IParams) =>
  httpPost<IApiRelative.IGetProList.IResData>("/subject/index", params, {
    header: {
      "content-type": IContentType.json
    }
  })
/**
 * 专业简介 专业详情
 * @param id 专业ID
 */
export const getProDetail = (id: number | string) =>
  httpGet<IApiRelative.IGetProDetail.IResData>("/subject/info/" + id)
/**
 * 获取城市信息
 */
export const getCityInfo = (params: IApiRelative.IGetCityInfo.IParams) =>
  httpPost<IApiRelative.IGetCityInfo.IResData>("/home/city-info", params, {
    header: {
      "content-type": IContentType.json
    }
  })
/**
 * 机构大全 筛选列表
 */
export const getInstitutionFilters = () =>
  httpGet<IApiRelative.IGetInstitutionFilters.IResData>("/agency/option")
/**
 * 机构大全 列表
 */
export const getInstitutionList = (params: IApiRelative.IGetInstitutionList.IParams) =>
  httpPost<IApiRelative.IGetInstitutionList.IResData>("/agency/index", params, {
    header: {
      "content-type": IContentType.json
    }
  })
/**
 * 城市选择面板
 */
export const getCityPanelData = () =>
  httpGet<IApiRelative.IGetCityPanelData.IResData>("/home/front-city")
/**
 * 机构排行 页面数据
 */
export const getRankingPageData = (query: IApiRelative.IGetRankingPageData.IParams) =>
  httpGet<IApiRelative.IGetRankingPageData.IResData>("/agency/ranking-option", query)
/**
 * 机构排行
 */
export const getRankingInstitution = (params: IApiRelative.IGetRankingInstitution.IParams) =>
  httpPost<IApiRelative.IGetRankingInstitution.IResData>("/agency/ranking", params, {
    header: {
      "content-type": IContentType.json
    }
  })
/**
 * 学员点评 页面数据
 */
export const getStuComments = () =>
  httpGet<IApiRelative.IGetStuComments.IResData>("/agency/comment")
/**
 * 留言咨询
 */
export const commitForm = (params: IApiRelative.ICommitForm.IParams) =>
  httpPost<unknown>("/home/reserve", params, {
    header: {
      "content-type": IContentType.json
    }
  })
/** 获取资讯模块详情 */
export const getModuleDetail = (params: IApiRelative.IGetModuleDetail.IParams) =>
  httpGet<IApiRelative.IGetModuleDetail.IResData>("/news/module/" + params.modulesId)
/** 获取资讯栏目详情 */
export const getNewsColumnDetail = (params: IApiRelative.IGetNewsColumnDetail.IParams) =>
  httpGet<IApiRelative.IGetNewsColumnDetail.IResData>("/news/column/" + params.columnId)
/** 获取专栏详情 */
export const getContentColumn = (params: IApiRelative.IGetContentColumn.IParams) =>
  httpGet<IApiRelative.IGetContentColumn.IResData>("/content-column/" + params.id)
